package com.vaeke.app.sina.focus;

import java.util.ArrayList;
import java.util.List;

import weibo4j.User;
import weibo4j.Weibo;

public class Friends {

    public List<User> getFriends(String accessToken, String accessTokenSecret) {
        System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
        System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);

        Weibo weibo = new Weibo();
        weibo.setToken(accessToken, accessTokenSecret);
        List<User> list = new ArrayList<User>();
        try {
            list = weibo.getFriendsStatuses();
        } catch (Exception e1) {
            e1.printStackTrace();
        }

        return list;
    }

    public List<String> getFriendNames(String accessToken, String accessTokenSecret) {
        List<User> userList = getFriends(accessToken, accessTokenSecret);
        List<String> nameList = new ArrayList<String>();
        for (User user : userList) {
            nameList.add(user.getName());
        }
        return nameList;
    }
}
